<?php
include('../../common.php');
if($_SESSION['log_islogin'] == 'yes' ){

	$id = intval(mysql_real_escape_string($_GET['recID']));
	$searchname = mysql_real_escape_string($_GET['searchname']);

	$clause = "ent_id='0'";
	if($id != null) {
		$clause = "ent_id='$id'";
	}else if($searchname != null) {
		$clause = "ent_short_name='$searchname' ";
	}

	$qList = "SELECT ent_short_name as receiver, ent_add_postcode, ent_add_city, ent_add_state FROM entity WHERE 1=1 AND ent_code is null AND $clause ";
	$rList = $db->sql_list($qList);	
	$name=$rList['receiver'];
	$postcode=$rList['ent_add_postcode'];
	$city=$rList['ent_add_city'];
	$state=$rList['ent_add_state'];

	if($state!= ""){
		$qState = "SELECT  name 
				FROM lookup_state 
				WHERE 1=1 AND code='$state' ";
		$rState = $db->sql_list($qState);	
		$state=$rState['name'];
	}

	if($postcode != "" && $city != "" && $state != ""){
		
		echo $result = $name.'$'.$postcode.'-'.$city.'-'.$state;

	}else if($name=='<NOT AVAILABLE>' || $name=='' || $name==null || (strlen($name) < 3) ){
		echo '-1';
	}else{
		echo $name;
	}
}else{
	echo 'Dude!';
}







?>